import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { type PermissionForm } from "./types";

/**
 * 获取权限列表
 *
 * @param params
 */
export function getPermissionList(params: any): AxiosPromise<ListResult<any>> {
  return request({
    url: "/api/admin_group_rule/index",
    method: "get",
    params: params,
  });
}

/**
 * 新建权限
 *
 * @param data
 */
export function addPermission(data: PermissionForm): AxiosPromise<DelResult> {
  return request({
    url: "/api/admin_group_rule/add",
    method: "post",
    data: data,
  });
}

/**
 * 编辑权限
 *
 * @param data
 */
export function editPermission(
  id: string | number,
  data: PermissionForm
): AxiosPromise<DelResult> {
  return request({
    url: `/api/admin_group_rule/edit/id/${id}`,
    method: "post",
    data: data,
  });
}

/**
 * 删除权限
 *
 * @param params
 */
export function deletePermissionList(
  ids: string,
  params: any
): AxiosPromise<DelResult> {
  return request({
    url: `/api/admin_group_rule/del/ids/${ids}`,
    method: "get",
    params: params,
  });
}
